package com.beigai.imessage.dao.mapper;

import com.beigai.imessage.dao.po.UserImagePO;
import org.apache.ibatis.jdbc.SQL;

public class UserImagePOSqlProvider {

    public String insertSelective(UserImagePO record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("user_image");
        
        if (record.getUserCode() != null) {
            sql.VALUES("user_code", "#{userCode,jdbcType=VARCHAR}");
        }
        
        if (record.getOriginalFileName() != null) {
            sql.VALUES("original_file_name", "#{originalFileName,jdbcType=VARCHAR}");
        }
        
        if (record.getRealFileName() != null) {
            sql.VALUES("real_file_name", "#{realFileName,jdbcType=VARCHAR}");
        }
        
        if (record.getFileMd5() != null) {
            sql.VALUES("file_md5", "#{fileMd5,jdbcType=VARCHAR}");
        }
        
        if (record.getCreateTime() != null) {
            sql.VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getUpdateTime() != null) {
            sql.VALUES("update_time", "#{updateTime,jdbcType=TIMESTAMP}");
        }
        
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(UserImagePO record) {
        SQL sql = new SQL();
        sql.UPDATE("user_image");
        
        if (record.getUserCode() != null) {
            sql.SET("user_code = #{userCode,jdbcType=VARCHAR}");
        }
        
        if (record.getOriginalFileName() != null) {
            sql.SET("original_file_name = #{originalFileName,jdbcType=VARCHAR}");
        }
        
        if (record.getRealFileName() != null) {
            sql.SET("real_file_name = #{realFileName,jdbcType=VARCHAR}");
        }
        
        if (record.getFileMd5() != null) {
            sql.SET("file_md5 = #{fileMd5,jdbcType=VARCHAR}");
        }
        
        if (record.getCreateTime() != null) {
            sql.SET("create_time = #{createTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getUpdateTime() != null) {
            sql.SET("update_time = #{updateTime,jdbcType=TIMESTAMP}");
        }
        
        sql.WHERE("id = #{id,jdbcType=BIGINT}");
        
        return sql.toString();
    }
}